package com.fbinggun.fattribute.effect;

import com.fbinggun.fattribute.data.EntityData;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class BanMoveEffect extends IEffect{
    boolean tick=true;
    public BanMoveEffect(int duration, double modification, EntityData source) {
        super(duration, modification, source);
    }

    @Override
    public void tick(EntityData entityData) {
        if(tick) {
            LivingEntity entity = entityData.getEntity();
            entity.addPotionEffect(new PotionEffect(PotionEffectType.
                    SLOW, (int) (getModification()), 99, true));
            if(entity instanceof Player) {
                entity.sendMessage("§c你被禁锢了");
                source.getEntity().sendMessage("§a你禁锢了" + entity.getName() + "");
            }
            tick=false;
        }
    }
}
